#include <iostream>
#include <vector>
#include <functional>

// 定义事件类型
enum class EventType {Click, Hover, KeyPress};

// 事件监听器接口
class EventListener
{
private:
    /* data */
public:
    // EventListener(/* args */);
    virtual ~EventListener() = default;
    virtual void onEvent(EventType type) = 0;
};


// 具体的监听器
class ClickLogger : public EventListener
{
private:
    /* data */
public:
    ClickLogger(/* args */);
    ~ClickLogger();
    void onEvent(EventType type) override {
        if (type == EventType::Click)
        {
            std::cout << "Click event logged" << std::endl;
        }
        
    }
};

ClickLogger::ClickLogger(/* args */)
{
}

ClickLogger::~ClickLogger()
{
}

// 触发事件
class Button
{
private:
    std::vector<EventListener*> listeners;
public:
    Button(/* args */);
    ~Button();

    void addListener(EventListener* listener) {
        listeners.push_back(listener);
    }

    void click() {
        for (auto listener : listeners) {
            listener->onEvent(EventType::Click);
        }
    }
};

Button::Button(/* args */)
{
}

Button::~Button()
{
}

int main() {
    Button button;
    ClickLogger logger;

    button.addListener(&logger);
    

    //触发事件
    button.click();

    return 0;
}

